package eightPuzzle;

import java.util.ArrayList;
import java.util.PriorityQueue;

import eightPuzzle.State.moveEmptyField;

public class Game {
	private int[][] _gameField;
	private int _fieldSize;
	private int expands;
	private State _startState;
	private State _endState;
	private State _currState;
	private static int _size;
	private Strategy _strategy;
	private PriorityQueue<State> _openList = null;
	private ArrayList<State> _closeList = null;

	public Game(State start, State dest, Strategy.Type type) {
		_gameField = new int[3][3];
		_fieldSize = _gameField.length;
		_startState = start;
		_currState = start;
		_endState = dest;

		setStateType(type);
		// openList.add(start);

	}

	private void setStateType(Strategy.Type type) {
		switch (type) {
		case NO_HEURISTIC:
			_strategy = new NoHeuristic();
			break;
		}
	}

	public void calcSolution() {

		while (!_openList.isEmpty()) {
			_currState = _openList.poll();
			expands++;

			if (_currState.equals(_endState)) {
				_endState = _currState;
				return;
			}
			_closeList.add(_currState);
			for (State st : _openList) {
				if(_closeList.contains(st)){
					
				}
			}
		}
	}

	public void possibleMoves(State s){
		State successor = s;
		State newState;
		
		ArrayList<State> possibillities = new ArrayList<State>();
		
		//nach links schauen
		if(s.getFreeField_i() +1 < _fieldSize){
			//change state
			//newState = successor.changeState(moveEmptyField.LEFT);
		}
	}
	
	public State getEndState() {
		return _endState;
	}

	public void setEndState(State end) {
		_endState = end;
	}

	public State getCurrState() {
		return _currState;
	}

	public void setCurrState(State curr) {
		_currState = curr;
	}

	public State getCurState() {
		return _currState;
	}
}
